from .MqttTools import Sender, Receiver


def sendMQTT_transport_car(msg, times=1, sleepNum=0):
    from .ServerConnectParameters import transport_car
    import random, time

    sender = Sender(
        transport_car(),
        f"python-mqtt-{random.randint(0, 1000)}"
    )
    for i in range(times):
        sender.send(msg, retain=True)
        # print("发送MQTT！")
        # time.sleep(sleepNum / 1000)


def sendMQTT_car_count(msg, times=1, sleepNum=0):
    from .ServerConnectParameters import car_count
    import random, time

    sender = Sender(
        car_count(),
        f"python-mqtt-{random.randint(0, 1000)}"
    )
    for i in range(times):
        sender.send(msg, retain=True)
        # print("发送MQTT！")
        # time.sleep(sleepNum / 1000)